<template>
    <!-- 收货地址 -->
    <van-contact-card type="edit" :name="`${address.consignee} ${address.region_text}`" :tel="address.mobile" @click="AddressShow = true" />

    <!-- 物流公司 -->
    <van-field
        label="物流公司"
        v-model="order.name"
        readonly
    />

    <van-field
        label="物流单号"
        v-model="order.code"
        readonly
    />

    <van-field
        label="物流状态"
        v-model="order.status"
        readonly
    />

    <!-- 物流进度 -->
    <van-steps v-if="express.length > 0" direction="vertical" :active="0">
        <van-step v-for="item in express" :key="item.time">
            <h3>{{item.status}}</h3>
            <p>{{item.time}}</p>
        </van-step>
    </van-steps>
</template>

<script setup>
    const { proxy } = getCurrentInstance();

    const business = proxy.$business;
    const orderid = ref(proxy.$route.query.orderid ?? 0);

    const order = ref({
        name: '',
        code: '',
        status: ''
    });

    const address = ref({});
    const AddressShow = ref(false);
    const express = ref([]);

    onBeforeMount(() => GetExpressInfo());

    const GetExpressInfo = async () =>
    {
        let params = {
            orderid:orderid.value,
            busid:business.value.id
        }

        let result = await proxy.$POST({
            url:'/order/express',
            params
        })

        if(result.code === 1)
        {
            address.value = result.data.address;
            order.value = result.data.order;
            express.value = result.data.express;
        }else{
            proxy.$fail(result.msg);
        }
    }
</script>